package hu.issue.framework.web.validation;

import java.text.SimpleDateFormat;

public class DateValidator extends NotRequiredValidator {
	private final String dateFormat;

	public DateValidator(final String parameterName, final String message, final String dateFormat) {
		super(parameterName, message);
		this.dateFormat = dateFormat;
	}

	@Override
	protected boolean validateValueInner(final String value) {
		final SimpleDateFormat format = new SimpleDateFormat(this.dateFormat);
		try {
			format.parse(value);
			return true;
		} catch (final Exception ex) {
			return false;
		}

	}

}
